package org.jcc.core.cs.extend;

public class ExtendSaveService {
	
	public Entity save(Entity e) {
		// TODO pseudo code
		// insert e into table e.realType
		return e;
	}
	
	public static void main(String[] args) {
		ExtendSaveService service = new ExtendSaveService();
		
		// ...
		Student s = new Student();
		Teacher t = new Teacher();
		
		// ...
		// 丢失子类型
		Entity es = service.save(s);
		Entity et = service.save(t);
		
		// ...
		// 强制类型转换
		Student ss = (Student)service.save(s);
		Teacher tt = (Teacher)service.save(t);
		
		System.out.println(es);
		System.out.println(et);
		System.out.println(ss);
		System.out.println(tt);
	}

}
